package com.sfx.other.多线程样例测试;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-08-07
 * Time: 10:43
 */
public class ThreadLocalTest1 {

    //1.创建一个线程本地变量
    private static InheritableThreadLocal<String> t = new InheritableThreadLocal<>();

    public static void main(String[] args) {
        //2.设置val
        //3.创建出一个子线程
        t.set("hello,world");
        new Thread(()->{
            System.out.println("thread1: " + t.get());
        }).start();;
        System.out.println("main: " + t.get());
    }
}